package io.github.controller.admin;

import com.baomidou.mybatisplus.plugins.Page;
import io.github.entity.SysCallStatisticsEntity;
import io.github.entity.SysCallogsEntity;
import io.github.entity.SysPageEntity;
import io.github.entity.SysUserEntity;
import io.github.service.SysCallStatictiscService;
import io.github.service.SysCalllogsService;
import io.github.util.ExcelUtil;
import io.github.util.PageUtils;
import io.github.util.R;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: weil
 * @date: 2019/9/18 20:27
 * @version: 1.0
 * @description: 呼叫统计控制器
 */
@Controller
@RequestMapping("/admin/sys/statistics")
public class SysCallStatisticsController extends AbstractController {

    @Resource
    private SysCallStatictiscService sysCallStatictiscService;

    /**
     * 所有通话记录列表
     */
    @RequestMapping("/list")
    @ResponseBody
    public R list() {
        logger.info("呼叫统计");
        List<SysCallStatisticsEntity> result = sysCallStatictiscService.listStatistics();
        return R.ok().put("data",result);
    }



    /**
     * 导出数据
     */
//    @RequestMapping("/export")
//    //@RequiresPermissions("sys:logs:export")
//    @ResponseBody
//    public R export(HttpServletResponse response) throws Exception {
//
//
//        List<List<String>> excelData = new ArrayList<>();
//
//        //表头
//        List<String> head = new ArrayList<>();
//
//        //获取所有记录数据
//        List<SysCallogsEntity> list = sysCallStatictiscService.queryAllLogs();
//
//        //遍历记录数据
//        for (int i = 0; i < list.size(); i++) {
//            //获取每行显示的数据
//            List<String> data = new ArrayList<>();
//            data.add(list.get(i).getCallee());
//            data.add(list.get(i).getCaller());
//            data.add(list.get(i).getCalleeRingTime());
//            data.add(list.get(i).getDuration());
//            //将数据添加到excel中
//            excelData.add(data);
//        }
//
//        //表头添加到excel
//        excelData.add(head);
//
//        String sheetName = "data";
//        String fileName = "data.xls";
//
//        //将数据导出
//        ExcelUtil.exportExcel(response, excelData, sheetName, fileName, 15);
//
//        return R.ok();
//    }


}
